from django.shortcuts import render
from rest_framework.response import Response
from rest_framework.views import APIView
from .models import *
# Create your views here.
class Dr(APIView):
    def get(self,request):
        data=Yh.objects.all()
        lst=[]
        for i in data:
            lst.append({
                'id':i.id,
                'name':i.name,
                'pwd':i.pwd
            })
        return Response(lst)

class Hyview(APIView):
    def get(self, request):
        data=Hy.objects.all()
        lst=[]
        for i in data:
            lst.append({
                'id':i.id,
                'hyi':i.hyi,
                'price':i.price
            })
        return Response(lst)

class Xqview(APIView):
    def get(self,request):
        data=Xq.objects.all()
        lst=[]
        for i in data:
            lst.append({
                'id':i.id,
                'jg':i.jg,
                'fa':i.fa,
                'yu':i.yu,
                'fw':i.fw,
                'sp':i.sp,
                'jd':i.jd
            })
        return Response(lst)
